<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="span12">

<form id="userForm" action='<c:url value="/system/user/" />' class="form-horizontal" method="post">
	<fieldset>
		<c:if test="${message != null }">
			<div class="alert alert-success">
				<c:out value="${message }" />
			</div>
		</c:if>
		
		<legend>用戶管理(admin)</legend>
		<div class="control-group">
			<label class="control-label" for="inputPassword">用户名</label>
			<div class="controls">
				<span class="input-large uneditable-input">${user.userName }</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="oldPassword">旧密码</label>
			<div class="controls">
				<input type="password" id="oldPassword" name="oldPassword" placeholder="用户的旧密码">
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="newPassword">新密码</label>
			<div class="controls">
				<input type="password" id="newPassword" name="newPassword" placeholder="如果需要修改密码，请输入新密码">
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="newPassword2">新密码</label>
			<div class="controls">
				<input type="password" id="newPassword2" name="newPassword2" placeholder="两次新密码必须一致">
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="email">电子邮箱</label>
			<div class="controls">
				<input type="text" id="email" name="email" placeholder="电子邮箱(通知服务用)">
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="phone">手机号</label>
			<div class="controls">
				<input type="text" id="phone" name="phone" placeholder="手机号(通知服务用)">
			</div>
		</div>
		
		<div class="control-group">
			<div class="controls">
				<button type="submit" class="btn">保存</button>
			</div>
		</div>
	
	</fieldset>
</form>
</div>

<script type="text/javascript">
    $(document).ready(function(){   
    	//defaults
    	$.validator.setDefaults({
    		submitHandler: function(form) {    
    			form.submit();    
    		}
    	});
    	
    	//begin to validate
    	$('#userForm').validate({  
    		debug:true,
    		rules: {
    			oldPassword:{
    				required:true
    			},
    			newPassword:{
    				required:true
    			},
    			newPassword:{
    				required:true,
    				equalTo:'#newPassword2'
    			},
    			email:{
    				email:true
    			},
    			phone:{
    				rangelength:[11,11]
    			}
    		},
    		messages:{
    			oldPassword: {       
    				required:"请填写旧密码"
    			},
    			newPassword:{
    				required:"请填写新密码",
    				equalTo:"两次新密码输入不一致"
    			},
    			newPassword2:{
    				required:"请重复填写新密码",
    				equalTo:"两次新密码输入不一致"
    			},
    			email:{
    				email:"请输入合法email"
    			},
    			phone:{
    				rangelength:"请输入合法手机号"
    			}
    		}
    	});
    });
    
    </script>


